import {
  AddExtendQuestionRequest,
  DeleteExtendQuestionRequest,
  ExtendQuestionsInfo,
  ExtendQuestionsRequest,
  ModifyExtendQuestionRequest,
  CheckNewWordsRequest,
  GetWordGroupsRequest,
  WordGroupsInfo,
  CheckNewWordsInfo,
  SaveNewWordsRequest,
  UnderstandNewWordsRequest,
  PostTraingrammarRequest,
  BatchUnderstandNewWordsRequest,
  BatchStudyProgressResponse,
} from 'admin/schema/ExtendQuestion';
import $http from '../../../servers/http';
import { Result } from '../../schema/Result';
/* 扩展问题相关
---------------------------------------------------------------- */
/**
 * 创建扩展问题
 */
export const addExtendQuestion = (
  data: AddExtendQuestionRequest
): Promise<Result<{ extendQuestionId: number }>> => {
  return $http.post({
    url: '/robotmanage/extendquestions',
    data,
  });
};

/**
 * 编辑扩展问题
 */
export const modifyExtendQuestion = (data: ModifyExtendQuestionRequest): Promise<Result<null>> => {
  return $http.put({
    url: `/robotmanage/extendquestions/${data.extendQuestionId}`,
    data,
  });
};

/**
 * 查询扩展问题列表
 */
export const getExtendQuestions = (
  data: ExtendQuestionsRequest
): Promise<Result<ExtendQuestionsInfo[]>> => {
  return $http.get({
    url: '/robotmanage/extendquestions',
    data,
  });
};

/**
 * 删除扩展问题
 */
export const deleteExtendQuestion = (data: DeleteExtendQuestionRequest): Promise<Result<{}>> => {
  return $http.delete({
    url: `/robotmanage/extendquestions/${data.extendQuestionId}`,
    data,
  });
};

/**
 * 获得词组
 */
export const getWordGroups = (data: GetWordGroupsRequest): Promise<Result<WordGroupsInfo[]>> => {
  return $http.get({
    url: `/robotmanage/extendquestions/wordgroups/${data.versionId}`,
    data,
  });
};

/**
 * 发现新词
 */
export const getNewWords = (data: CheckNewWordsRequest): Promise<Result<CheckNewWordsInfo>> => {
  return $http.post({
    url: `/robotmanage/extendquestions/discovernewwords`,
    data,
  });
};
/**
 * 保存新词
 */
export const saveNewWords = (data: SaveNewWordsRequest): Promise<Result<{}>> => {
  return $http.post({
    url: `/robotmanage/extendquestions/savenewwords`,
    data,
  });
};

/**
 * 语义文法
 */
export const postTraingrammar = (data: PostTraingrammarRequest): Promise<Result<{}>> => {
  return $http.post({
    url: `/robotmanage/extendquestions/traingrammar`,
    data,
  });
};

/**
 * 语义学习
 */
export const understandNewWords = (data: UnderstandNewWordsRequest): Promise<Result<{}>> => {
  return $http.post({
    url: `/robotmanage/extendquestions/understand`,
    data,
  });
};

/**
 * 语义批量学习
 */
export const batchUnderstandNewWords = (
  data: BatchUnderstandNewWordsRequest
): Promise<Result<{}>> => {
  return $http.post({
    url: `/robotmanage/extendquestions/batchunderstand`,
    data,
  });
};

/**
 * 语义批量学习进度查询
 */
export const getBatchStudyProgress = (
  data: BatchUnderstandNewWordsRequest
): Promise<Result<BatchStudyProgressResponse>> => {
  return $http.get({
    url: `/robotmanage/extendquestions/batchunderstandprogress`,
    data,
  });
};
